<!DOCTYPE html>
<html>
<head> 
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
</script>
<title>esp32</title> 
<style type="text/css">
body
{
	background-image:url('http://pic1.win4000.com/mobile/2020-07-16/5f1011e602c5a.jpg');
	background-repeat:no-repeat;
	background-size:100%;
}
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 5px 15px;
    text-align: center;
    font-size: 16px;
}
.input1
{
	border:2px solid #a1a1a1;
	padding:5px 20px; 
	background:#dddddd;
	width:30%;
	border-radius:15px;
	margin-top: 10px;
	margin-bottom: 10px;
}
</style>

</head>
<body>
<center><h1>web设置界面</h1></center>
<h2>必填</h2>
<center> 
哔哩哔哩uid<br>
<input class="input1"  type="text" id="uid"><br>
所在城市拼音<br>
<input class="input1"  type="text" id="city"><br>
<button class="button" id="up">提交</button>
</center>


<h2>选填</h2>
<center> 心知天气id <br>
<input class="input1" type="text" id="id"><br>
天气密匙 <br>
<input class="input1" type="text" id="pass"><br>
<button class="button" id="up2">提交</button>
</center>

<br>

哔哩哔哩uid初始为up的id，城市为nanjing(南京)，由于使用的是up自己申请的心知天气id，每日访问存在上线，如果想要更好的体验，请更换为自己的id和密匙
</body>
<script>
$(document).ready(function(){
// 传参数 
var aa = function(x){ 
    var re = /^\w{3,30}$/

        if (x == '') {
            alert('不能为空');
            return 1;
        }
        if (re.test(x)) {
            // 合法 -- 隐藏报错信息
            return 0;
        } else {
            alert('必须为6-20位数字、字母和下划线！');
         	 return 1;
        }
	} 
$.test = aa; 
  $("#up").click(function(){
  	var uid= $("#uid").val();
	var city= $("#city").val();

	if($.test(uid))
	{
		return;
	}
	if($.test(city))
	{
		return;
	}
	var str=JSON.stringify({"n":1,"uid":uid,"city":city});
  	$.post("/must",
    str,
    function(data,status){
        alert("数据: \n" + data + "\n状态: " + status);
    });
  });

    $("#up2").click(function(){
  	var id= $("#id").val();
	var pass= $("#pass").val();
	var str=JSON.stringify({"n":0,"id":id,"pass":pass});
  	$.post("/must",
    str,
    function(data,status){
        alert("数据: \n" + data + "\n状态: " + status);
    });
  });
});
</script>
</html>